export default {
  data() {
    return {
      loading: false,
      // 查询数据
      queryParams: {
        page: 1,
        size: 10
      },
      // 分页结果
      pageData: {
        total: 0,
        rows: []
      },
      //表单多选对象
      mutilrows:[],
      //表单多选主键的值
      ids: [],
      // 修改按钮是否禁用
      single: true,
      // 删除按钮是否禁用
      multiple: true,
      uploadFileUrl: 'http://localhost:8080/api/upload'
    }
  },
  methods: {
    // 搜索
    handleQuery(){
      this.queryParams.page =1
      this.fetchData()
    },
    // 查询重置
    resetQuery() {
      this.$refs['queryForm'].resetFields();
      this.custReset()
      this.fetchData()
    },
    // 自定义重置表单查询方法(预留的钩子函数)
    custReset(){
    },
    // 员工查询
    fetchData(){
      this.loading=true
      getList(this.queryParams).then( resp => {
        this.pageData = resp
        this.loading=false
      })
    },
    handleSizeChange(val) {
      this.queryParams.page =1
      this.queryParams.size= val
      this.fetchData()
    },
    handleCurrentChange(val) {
      this.queryParams.page =val
      this.fetchData()
    },
    //表格多选改变事件
    handleSelectionChange(val){
      this.mutilrows=val
      this.ids =val.filter(s=> s.id!==1).map( p => p.id)
      // 删除按钮
      this.multiple = !(val.length>0)
      if(val.length==1){
        const result=this.ids.some(p => p===1)
        console.log(result)
        this.single =result
      }else{
        this.single =true
      }
    }
  },
  created() {
    this.fetchData()
  }
}
